<template>
  <el-card>
    <div class="box">
      <img :src="userStore.avatar" alt="" />
      <div class="bottom">
        <p class="title">{{ getTime() }}好呀，{{ userStore.username }}</p>
        <p class="wel">欢迎</p>
      </div>
    </div>
  </el-card>
  <div class="bottoms">
    <div class="echarts" ref="charts"></div>
    <svg-icon name="welcome" width="500px" height="300px"></svg-icon>
  </div>
</template>

<script setup lang="ts">
//引入用户相关的仓库,获取当前用户的头像、昵称
import useUserStore from '@/store/modules/user'
import { onMounted, ref } from 'vue'
import { getTime } from '@/util/time.ts'
import * as echarts from 'echarts'
import 'echarts-gl'

// const ROOT_PATH = 'http://localhost:5173/src';
import pi from '../../assets/images/earth.jpg'
import po from '../../assets/images/starfield.jpg'

let charts = ref()
//获取存储用户信息的仓库对象
let userStore = useUserStore()
onMounted(() => {
  let myChart = echarts.init(charts.value)
  myChart.setOption({
    backgroundColor: '#000',
    globe: {
      baseTexture: pi,
      shading: 'lambert',
      environment: po,
      atmosphere: {
        show: true,
      },
      light: {
        ambient: {
          intensity: 0.1,
        },
        main: {
          intensity: 1.5,
        },
      },
    },
    series: [],
  })
})
</script>

<style scoped lang="scss">
.box {
  display: flex;

  img {
    width: 100px;
    height: 100px;
    border-radius: 50px;
  }

  .bottom {
    margin-left: 20px;

    .title {
      font-size: 30px;
      font-weight: 900;
      margin-bottom: 30px;
    }

    .wel {
      font-style: italic;
      color: skyblue;
    }
  }
}

.bottoms {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background-color: black;

  .echarts {
    width: 900px;
    height: 300px;
  }
}
</style>
